package cn.sh.yhk.file;

import io.minio.MinioClient;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Classname Yhk
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/10/16 19:14
 * @Created by y6522
 */
@Data
@Component
@Slf4j
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
    /**
     * 连接地址
     */
    private String endpoint;
    /**
     * 用户名
     */
    private String accesskey;
    /**
     * 密码
     */
    private String secretkey;

    /**
     * 获取MinioClient
     */
    @Bean
    public MinioClient minioClient() {
        log.info("MinioClient:{}",endpoint);
        MinioClient minioClient = MinioClient.builder().endpoint(endpoint).credentials(accesskey, secretkey).build();
        log.info("MinioClient 初始化完成");
        return minioClient;
    }
}

